<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <script>
        class Father {
            //constructor创建构造函数
            constructor(x, y) {
                this.x = x;
                this.y = y;
            }
            sum() {
                console.log(this.x + this.y);
            }
        }
        var a = new Father(20, 30);
        a.sum();

        //extends继承父类
        class Son extends Father {
            constructor(x, y) {
                //super用于访问和调用父类函数
                super(x, y);
            }
        }
        var b = new Son(10, 20);
        b.sum();
    </script>
</body>

</html>